home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / xfcn / spttool.cpt / Support Tools eXternals 1.2.5 / card_41583.txt < prev    next >
Text File  |  1990-11-13  |  7KB  |  202 lines

  1. -- card: 41583 from stack: in.5
  2. -- bmap block id: 46055
  3. -- flags: 0000
  4. -- background id: 3858
  5. -- name: VolumeList
  6. ----- HyperTalk script -----
  7. on CloseCard
  8.   put empty into cd fld "volume list"
  9.   put empty into cd fld "label"
  10.   set the scroll of cd fld "volume list" to 0
  11.   pass CloseCard
  12. end CloseCard
  13.  
  14. on HideObjects
  15.   hide cd fld "volume list"
  16.   hide cd fld "label"
  17.   hide cd btn "try it!"
  18. end HideObjects
  19.  
  20. on ShowObjects
  21.   show cd fld "volume list"
  22.   show cd fld "label"
  23.   show cd btn "try it!"
  24. end ShowObjects
  25.  
  26.  
  27. -- part 1 (button)
  28. -- low flags: 00
  29. -- high flags: A002
  30. -- rect: left=82 top=292 right=326 bottom=175
  31. -- title width / last selected line: 0
  32. -- icon id / first selected line: 0 / 0
  33. -- text alignment: 1
  34. -- font id: 0
  35. -- text size: 12
  36. -- style flags: 8192
  37. -- line height: 16
  38. -- part name: Try It!
  39. ----- HyperTalk script -----
  40. on mouseUp
  41.   global errGlobal
  42.   put VolumeList(newVolume, "noDialog:errGlobal") into volumes
  43.   if errGlobal Γëá empty then
  44.     answer "Error:" && errGlobal
  45.     put empty into errGlobal
  46.   else
  47.     put volumes into cd fld "volume list"
  48.     put "Currently mounted volumes" into cd fld "label"
  49.   end if
  50. end mouseUp
  51.  
  52.  
  53.  
  54.  
  55. -- part 2 (field)
  56. -- low flags: 00
  57. -- high flags: 0007
  58. -- rect: left=19 top=117 right=288 bottom=236
  59. -- title width / last selected line: 0
  60. -- icon id / first selected line: 0 / 0
  61. -- text alignment: 0
  62. -- font id: 4
  63. -- text size: 9
  64. -- style flags: 0
  65. -- line height: 12
  66. -- part name: volume list
  67.  
  68.  
  69. -- part 3 (field)
  70. -- low flags: 00
  71. -- high flags: 0000
  72. -- rect: left=19 top=101 right=118 bottom=236
  73. -- title width / last selected line: 0
  74. -- icon id / first selected line: 0 / 0
  75. -- text alignment: 0
  76. -- font id: 3
  77. -- text size: 9
  78. -- style flags: 256
  79. -- line height: 12
  80. -- part name: label
  81.  
  82.  
  83. -- part contents for background part 38
  84. ----- text -----
  85. 49/50
  86.  
  87. -- part contents for background part 20
  88. ----- text -----
  89.      An XFCN which returns a carraige return delimited list of all currently mounted volumes.
  90.  
  91.      Calling syntax : VolumeList(<"noDialog:"errorGlobal>)
  92.  
  93.  
  94. -- part contents for background part 42
  95. ----- text -----
  96. { VolumeList(   )                                                   }
  97. { XFCN returns a CR delimited list of the names of all          }
  98. { mounted volumes.                                                }
  99. {}
  100. {   brought to you by:      Anup Murarka             Eric Carlson         }
  101. {                       ALINK:  SKEPTIC           ALINK:  cyNic   }
  102. {                                   CIS:  76004,3356         }
  103. {}
  104. {               We are part of the Support Tools Development Group,     }
  105. {               Apple Computer, Inc.      }
  106. {}
  107. {               please DO NOT contack Mac DTS for support of this code!    }
  108. {}
  109. {               please DO contact the authors for support of this code!     }
  110. {}
  111. {               Send comments, bug reports, requests to any of the above   }
  112. {               E-mail addresses or to:}
  113. {}
  114. {                           (one of us)                  }
  115. {                           Apple Computer, Inc.          }
  116. {                           900 E. Hamilton, Ave.          }
  117. {                           Campbell, CA   95008      }
  118. {                           M/S 72-L                     }
  119. {}
  120. {   Copyright:   ┬⌐ 1989, 1990 by Apple Computer, Inc., all rights reserved.     }
  121. {}
  122. { written by Eric Carlson                                        }
  123. { AppleLink:  cyNic                                              }
  124. { modification history                                                                                        }
  125. {          Date                  Initials                                    Comments                               }
  126. {          ----              ------          ------------------------------------------------}
  127. {       12/16/89             ec            first written                                                       }
  128. {       6/3/90                 ec            additonal comments                                               }
  129. {}
  130. unit VolumeList;
  131.  
  132. interface
  133.  
  134.     uses
  135.         hyperXCmd;
  136.  
  137.     procedure MAIN (paramPtr: XCmdPtr);
  138.  
  139. implementation
  140.  
  141.     function askedForHelp (paramPtr: XCmdPtr;
  142.                                     syntaxMsg: Str255;
  143.                                     copyRightMsg: Str255): boolean;
  144. {}
  145. {   check to see if the user sent a '?' or a '!' as }
  146. { the only parameter. if so we will respond with }
  147. { the calling syntax or the copyright/version info }
  148. { for this external }
  149. {}
  150.         var
  151.             firstStr: str255;
  152.     begin
  153.         askedForHelp := false;
  154.         if paramPtr^.paramCount = 1 then
  155.             begin
  156.                 ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr);
  157.                     { what is the first param? }
  158.                 if firstStr = '?' then
  159.                     begin
  160.                         paramPtr^.returnValue := PasToZero(paramPtr, syntaxMsg);
  161.                         askedForHelp := true
  162.                     end  { asked for help }
  163.                 else if firstStr = '!' then
  164.                     begin
  165.                         paramPtr^.returnValue := PasToZero(paramPtr, copyRightMsg);
  166.                         askedForHelp := true
  167.                     end;     { asked for copyright info }
  168.             end;     { one parameter passed }
  169.     end;     { function }
  170.  
  171.     procedure VolumeList (paramPtr: XCmdPtr);
  172.         var
  173.             volList, volName: str255;
  174.             PB: ParamBlockRec;
  175.             volInfoErr: OSErr;
  176.     begin
  177.         if askedForHelp(paramPtr, 'VolumeList()', '┬⌐1989, 1990 Apple Computer, Inc., v1.0 by Eric Carlson') then
  178.             exit(VolumeList);
  179.  
  180.         zeroBytes(paramPtr, @PB, sizeOf(PB));                         { clear out our paramblock }
  181.         PB.ioNamePtr := @volName;                                   { where to stick the vol name }
  182.         PB.ioVolIndex := 1;                                                  { start with the first mounted vol }
  183.         volList := '';
  184.         volInfoErr := PBGetVInfo(@PB, false);                           { get the first volume name }
  185.         while (volInfoErr = noErr) do                                     { loop through all volumes }
  186.             begin
  187.                 volList := concat(volList, volName, ':', chr(13));            { remember it, add a colon }
  188.                 PB.ioVolIndex := PB.ioVolIndex + 1;                       { next volume }
  189.                 volInfoErr := PBGetVInfo(@PB, false);                       { get the next volume name }
  190.             end;
  191.         if length(volList) > 0 then
  192.             volList := Omit(volList, length(volList), 1);                    { drop the trailing CR }
  193.  
  194.         paramPtr^.returnValue := PasToZero(paramPtr, volList);    { return the list }
  195.     end;         { procedure volumeList}
  196.  
  197.     procedure MAIN (paramPtr: XCmdPtr);
  198.     begin
  199.         VolumeList(paramPtr);
  200.     end;
  201.  
  202. end.     { unit VolumeList}